#pragma once
#include "State.h"

//D3dApp Constants:
#define DA_SCREENWIDTH_DEFAULT 640
#define DA_SCREENHEIGHT_DEFAULT 480

//D3dApp SCREEN MODE:
#define DA_SCREENMODE_NONE 0
#define DA_SCREENMODE_WINDOWED 0x1
#define DA_SCREENMODE_FULLSCREEN 0x10

class D3dApp
{
protected:
	LPSTR					m_sName;
	IDirect3D9*				m_pD3dObj;
	D3DDEVTYPE				m_devType;
	INT						m_supportedDASM;
	DWORD					m_vpMode;

	HWND					m_hWnd;
	HINSTANCE				m_hInstance;
	D3DPRESENT_PARAMETERS	m_d3dpp;

	State			*	m_pState;
protected:
	virtual bool isInCompatible();
public:
					D3dApp(HINSTANCE p_hInstance, LPSTR p_sName, D3DDEVTYPE p_devType = D3DDEVTYPE_HAL);
	virtual			~D3dApp();

	HWND			getWnd();
	HINSTANCE		getInstance();
	RECT			getRect();

	void			setState(State* p_pState);
	virtual bool	isDeviceReady();
	virtual void	onLostDevice();
	virtual void	onResetDevice();

	virtual bool	initDirectX();
	virtual bool	initWindow();
	virtual void	initState();
	virtual int		run();
	virtual LRESULT	msgProc(UINT p_uMsg, WPARAM p_wParam, LPARAM p_lParam);
};

extern D3dApp* g_pD3dApp;